<?php
class RedirectController extends Zend_Controller_Action {
	public function indexAction() {
		$this->_helper->layout ()->disableLayout ();
		$this->_helper->viewRenderer->setNoRender ();
		$authData = Zend_Auth::getInstance ()->getIdentity();
		if (is_array($authData) and $authData['identity'] != 'anon' and $authData) {
		    //User is logged in
		    $this->_helper->logger($authData);
		    $userSession = new Zend_Session_Namespace('userSession');
		    $userRoles = $authData['roles'];
		    if (array_search('admin', $userRoles)) {
		        $userSession->userHome = '/admin';
		        return $this->_helper->redirector ( 'index', 'index','admin' );
		    } elseif (array_search('employee', $userRoles)) {
		        $userSession->userHome = '/employee';
		        return $this->_helper->redirector ( 'index', 'index','employee' );
		    } elseif (array_search('agent', $userRoles)) {
		        $userSession->userHome = '/agent';
		        return $this->_helper->redirector ( 'index', 'index','agent' );
		    } else {
		        $userSession->userHome = '';
		        return $this->_helper->redirector ( 'index', 'index','default' );
		    }
		} else {
		    $authData = Zend_Auth::getInstance()->getIdentity();
		    $this->_helper->logger->warn('Unable to meet criteria.');
		    $this->_helper->logger($authData);
		    //return $this->_helper->redirector ( 'index', 'index','default' );
		    //return $this->_helper->redirector ( 'index', 'index' );
		}
	}
	
	protected function _decide($auth_id) {
	    ;
	}
}